<?php
class Controller_ProjectSpeed extends Controller_Website {
    
    public function action_list() {
        $m_projectSpeed = Model::factory('projectSpeed');
        $total = $m_projectSpeed->count();
        $pager = new Pager($total, 15);
        $projectSpeed = $m_projectSpeed->select($pager->offset, $pager->size)->as_array();
        
        $m_project = Model::factory('project');
        $project = $m_project->getAll()->as_array();
        foreach ($projectSpeed as &$item) {
            foreach ($project as $item2) {
                if ($item['project_id']==$item2['id']) {
                    $item['project_status']=$item2['status'];
                }
            }
        }
//         var_dump($projectSpeed);exit;
//    print_r($projectSpeed);exit;
        
        $this->content = View::factory('projectSpeed/list');
        $this->content->projectSpeed = $projectSpeed;
        $this->content->pager = $pager;
    }
    
    public function action_speed() {
        $id = $_GET['id'];
        $m_projectSpeed = Model::factory('projectSpeed');
        $projectSpeed = $m_projectSpeed->getRowById($id);
        
        $m_project = Model::factory('project');
        $project = $m_project->getRow(array('id'=>$projectSpeed['project_id']));
        
        $m_projectProp = Model::factory('projectProp');
        $projectProp = $m_projectProp->getRow(array(
            'project_cid'=>$project['project_cid'],
            'project_budget'=>$project['project_budget']
        ));
        $projectSpeed['projectProp']=$projectProp;
//         var_dump($projectSpeed);exit;
        $this->content = View::factory('projectSpeed/speed');
        $this->content->projectSpeed = $projectSpeed;
        $this->content->project = $project;
    }
}